#ifndef MODESELECTWIDGET_H
#define MODESELECTWIDGET_H

#include <QWidget>
#include <QPushButton>
#include <QLabel>
#include <QVector>
#include <QColor>
#include <QLayout>
#include <QIcon>
#include <QPushButton>
#include <QResizeEvent>
#include <QPropertyAnimation>

namespace Ui {
class ModeSelectWidget;
}

class SelectItem : public QPushButton {
    Q_OBJECT
public:
    SelectItem(QString iconPath, QWidget *parent = nullptr);
    ~SelectItem();
    bool m_selected = false;
    void select();
    void deSelect();

Q_SIGNALS:
    void selected(SelectItem *item);

private:
    QIcon *m_icon;
    QColor m_hoverColor = QColor(174, 214, 241);
//    QColor m_checkedColor = QColor(93, 173, 226);
    QColor m_checkedColor = QColor(133, 193, 233);
    QColor m_uncheckedColor = QColor(64, 224, 208);
    int m_cornerRadius;

protected:
    virtual void resizeEvent(QResizeEvent *event) override;
};

class ModeSelectWidget : public QWidget
{
    Q_OBJECT
public:
    enum Orientation{vertical = 0, horizontal = 1}; //方向

public:
    explicit ModeSelectWidget(QWidget *parent = nullptr);
    ModeSelectWidget(Orientation orientation, QWidget *parent = nullptr);
    ~ModeSelectWidget();

    void addItem(SelectItem *item);  //在末尾添加Btn
    int selectID(){return m_selectID;};
    void changePage(int index);

private:
    Ui::ModeSelectWidget *ui;
    QVector<SelectItem*> m_itemVector;   //里面具有的选项，使用PushButton形式
    //************选择指示器************//
    QWidget *m_indicator; //选择指示器
    QSize m_itemNormalSize = QSize(40, 40);
    QSize m_itemSelectedSize = QSize(50, 50);
    //************布局************//
    QLayout *m_layout;
    //************参数************//
    Orientation m_orientation;    //容器方向
    int m_selectID = -1;


Q_SIGNALS:
    void itemChange(int selectID);

private slots:
    void changeSelection(SelectItem *item);

};

#endif // MODESELECTWIDGET_H
